#include<stdio.h>
int main()
{
	int temp[4],score[4];int i,j;char card[20][3];int flag[20]={0};
	int pig(int flag[20]);
	do {
		for (i=0;i<4;i++)
		{
			scanf("%d",&temp[i]);
			if (temp[i]!=0)
			{
				for (j=0;j<temp[i];j++)
				{
					scanf("%s",card[j]);
					if (card[j][0]=='H')
					{
						if (card[j][2]=='\0') flag[j]=card[j][1]-48;
						else flag[j]=card[j][2]-38;
					}
					else if (card[j][0]=='S'){flag[j]=14;}
					else if (card[j][0]=='D'){flag[j]=15;}
					else if (card[j][0]=='C'){flag[j]=16;}
				}
				score[i]=pig(flag);
			}
			else score[i]=0;
			for (j=0;j<20;j++){card[j][0]=card[j][1]=card[j][2]=0;flag[j]=0;}
		}		   
		    if (temp[0]==0&&temp[1]==0&&temp[2]==0&&temp[3]==0)return 0;
		    for (i=0;i<4;i++)
		    {
		    	if (score[i]>0) printf("+%d",score[i]);
		    	else printf("%d",score[i]);
		    	if (i==3) printf("\n");
		    	else printf(" ");
			}
			for (i=0;i<4;i++){score[i]=0;temp[i]=0;}
	    }while (1);
 return 0;
} 
int pig(int flag[20])
{
	int m,n;int tip1=0,tip2=0,tip3=0,sum=0;
	if (flag[0]==16&&flag[1]==0) return 50;
	for (n=1;n<=13;n++)
	{
		tip1=1;
		for (m=0;m<20;m++)
		{
			if (flag[m]==n) tip1=0;
		}
		if (tip1==1) break;
	}
	if (tip1==1)
	{
		for (n=0;n<20;n++)
		{
			if (flag[n]==1) sum=sum-50;
			else if (flag[n]<=10&&flag[n]>=2) sum=sum-flag[n];
			else if (flag[n]>10&&flag[n]<=13) sum=sum-10*(flag[n]-9);
			else if (flag[n]==14) sum=sum-100;
			else if (flag[n]==15) sum=sum+100;
			else if (flag[n]==16) tip2=16;
		}
		if (tip2==16) return sum*2;
		else return sum;
	}
	else 
	{
		sum=200;
		for (n=0;n<20;n++)
		{
			if (flag[n]==14) tip1=14;
			if (flag[n]==15) tip2=15;
			if (flag[n]==16) tip3=16;
		}
		if (tip1==14&&tip2==15) sum+=300;
		else if (tip1==14&&tip2!=15) sum-=100;
		else if (tip1!=14&&tip2==15) sum+=100;
		if (tip3==16) return sum*2;
		else return sum;
	}
}